package com.example.videoplayer.repository;

import com.example.videoplayer.model.Video;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import reactor.core.publisher.Flux;

public interface VideoRepository extends ReactiveCrudRepository<Video, Long> {
    @Query("SELECT * FROM videos ORDER BY upload_time DESC LIMIT :limit OFFSET :offset")
    Flux<Video> findAllPaginated(int limit, int offset);

    @Query("SELECT * FROM videos WHERE category = :category ORDER BY upload_time DESC LIMIT :limit OFFSET :offset")
    Flux<Video> findByCategoryPaginated(String category, int limit, int offset);
} 